//
//  OMTResourceManager.m
//  BeautyCamera
//
//  Created by yizhaorong on 2017/9/19.
//  Copyright © 2017年 yizhaorong. All rights reserved.
//

#import "OMTResourceManager.h"
#import <OMTCache/OMTMemoryCache.h>

static NSBundle *_currentBundle = nil;

static NSString *_imageBasePath = nil;

static NSString *_localeBasePath = nil;

static NSString *_configBasePath = nil;

@implementation OMTResourceManager

+ (NSBundle *)currentBundle {
    if (!_currentBundle) {
        NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"Resources" ofType:@"bundle"];
        [OMTMemoryCache setMemoryValue:resourcePath key:OMTMemoryCacheCurrentBundlePath];
        _currentBundle = [NSBundle bundleWithPath:resourcePath];
        _imageBasePath = [resourcePath stringByAppendingPathComponent:@"images"];
        _localeBasePath = [resourcePath stringByAppendingPathComponent:@"locale"];
        _configBasePath = [resourcePath stringByAppendingPathComponent:@"config"];
    }
    return _currentBundle;
}

+ (NSString *)imageBasePath {
    [self currentBundle];
    return _imageBasePath;
}

+ (NSString *)localeBasePath {
    [self currentBundle];
    return _localeBasePath;
}

+ (NSString *)configBasePath {
    [self currentBundle];
    return _configBasePath;
}

+ (void)releaseResources {
    _currentBundle = nil;
    _imageBasePath = nil;
    _localeBasePath = nil;
    _configBasePath = nil;
}

@end
